# coding:utf-8
# 作者：理想国真恵玩
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

data = pd.read_csv("data/stock.csv")
# 寻找星期几跟股票张得的关系
# 1、先把对应的日期找到星期几
date = pd.to_datetime(data.index).weekday
data['week'] = date

# 2、假如把p_change按照大小去分个类0为界限
data['posi_neg'] = np.where(data['p_change'] > 0, 1, 0)

# 通过透视表，将整个过程变成更简单一些
result = data.pivot_table(['posi_neg'], index='week')
print(result)
